package Banking_5;


public class CheckingAccount extends Account{
    private double overdraft;//超额限额保护
    public CheckingAccount(double balance,double overd){
        super(balance);
        this.overdraft=overd;
    }
    public void showinfo(){
        System.out.println("您的余额:"+this.getBalance()+"\t"+
                "您的可透支余额:"+this.overdraft);
    }
    public Boolean withdraw(double amt){
        if(amt<=super.getBalance())
            super.setBalance(super.getBalance()-amt );
        else{
            double val=amt-super.getBalance();
            if(val<=this.overdraft)
            {
                super.setBalance(0);
                this.overdraft-=val;
            }
            else{
                System.out.println("该消费超过可透支额的限额");
                return false;
            }
        }
        return true;
    }
}